﻿namespace IPMS.BLL
{
    using IPMS.DAL;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    /// <summary>
    /// Summary description for ProjectDocument
    /// </summary>
    public class ProjectDocument
    {
        public ProjectDocument()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public bool Update(bool IsDelete, string UpdateBy, string UpdateIP, string Original_ProjectCode, string Original_FileName, string Original_Section, string Original_Type)
        {
            bool isSuccess = false;
            try
            {
                SqlCommand sqlCommand = new SqlCommand();
                DataAccessLayer DAL = new DataAccessLayer();

                string sqlString = "UPDATE [ProjectDocument] SET IsDelete = @IsDelete,UpdateBy = @UpdateBy,UpdateDate = GETDATE(), UpdateIP = @UpdateIP WHERE (([ProjectCode] = @Original_ProjectCode) AND (FileName = @Original_FileName) AND (Section = @Original_Section) AND (Type = @Original_Type)) ";

                DAL.SetCommandType(sqlCommand, CommandType.Text, sqlString);
                DAL.AddParamToSQLCmd(sqlCommand, "@IsDelete", SqlDbType.Bit, 1, ParameterDirection.Input, IsDelete);
                DAL.AddParamToSQLCmd(sqlCommand, "@UpdateBy", SqlDbType.NVarChar, 60, ParameterDirection.Input, UpdateBy);
                DAL.AddParamToSQLCmd(sqlCommand, "@UpdateIP", SqlDbType.NVarChar, 50, ParameterDirection.Input, UpdateIP);
                DAL.AddParamToSQLCmd(sqlCommand, "@Original_ProjectCode", SqlDbType.NVarChar, 60, ParameterDirection.Input, Original_ProjectCode);
                DAL.AddParamToSQLCmd(sqlCommand, "@Original_FileName", SqlDbType.NVarChar, 60, ParameterDirection.Input, Original_FileName);
                DAL.AddParamToSQLCmd(sqlCommand, "@Original_Section", SqlDbType.NVarChar, 60, ParameterDirection.Input, Original_Section);
                DAL.AddParamToSQLCmd(sqlCommand, "@Original_Type", SqlDbType.NVarChar, 60, ParameterDirection.Input, Original_Type);
                DAL.ExecuteScalarCmd(sqlCommand);

                isSuccess = true;
            }
            catch { }

            return isSuccess;
        }

    }
}
